<?php
/**
 * Notes:
 * User:ZSLAA
 * DateTime: 2020/11/5 15:16
 */

namespace app\commom;


use think\facade\Config;

class BaiDuApi
{
    public static function getAipNlp(){
        $config = Config::get('nlp_baidu');
        $aipNlp = new \AipNlp($config['AppId'],$config['ApiKey'],$config['SecretKey']);
        return $aipNlp;
    }
    //通过文章标题文章内容获取该文章的标签
    public static function CreateTags($title,$content){
        $aipNlp = self::getAipNlp();
        //百度获取文章标签
        $tags = $aipNlp->keyword($title, $content);
        return $tags;
    }
    //获取文章分类
    public static function getCategory($title,$content){
        $aipNlp = self::getAipNlp();
        // 调用文章分类
        $topic = $aipNlp->topic($title, $content);
        return $topic;
    }

    //文章摘要  此处准备作为文章seo的描述
    public static function getDescription($content, $maxSummaryLen){
        $aipNlp = self::getAipNlp();
        $summary = $aipNlp->newsSummary($content, $maxSummaryLen);
        return $summary;
    }
    //调用DNN语言模型
    public static function  getDNN($content){
        $aipNlp = self::getAipNlp();
        $dnnlm = $aipNlp->dnnlm($content);
        return $dnnlm;
    }

}